package com.api.shopapi.mapper;


import com.api.shopapi.entity.OrderServe;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface OrderServeMapper {

    @Insert("insert into order_serve" +
            "(" +
            "OrderServeCode," +
            "OrderBusinessCode," +
            "StartTime," +
            "EndTime," +
            "UserCode," +
            "CreateTime" +
            ")" +
            "values" +
            "(" +
            "#{orderServe.OrderServeCode}," +
            "#{orderServe.OrderBusinessCode}," +
            "#{orderServe.StartTime}," +
            "#{orderServe.EndTime}," +
            "#{orderServe.UserCode}," +
            "#{orderServe.CreateTime}" +
            ")")
    public int insert(@Param("orderServe") OrderServe orderServe);

    @Delete("delete from order_serve where orderServeCode=#{orderServeCode}")
    public int delete(@Param("orderServeCode") String orderServeCode);

    @Update("update order_serve set " +
            "OrderBusinessCode = #{orderServe.OrderBusinessCode}," +
            "StartTime = #{orderServe.StartTime}," +
            "EndTime = #{orderServe.EndTime}," +
            "UserCode = #{orderServe.UserCode}"+
            " where OrderServeCode=#{orderServe.OrderServeCode}")
    public int update(@Param("orderServe") OrderServe orderServe);

    @Select("select * from order_serve")
    public List<OrderServe> getList();

    @Select("select * from order_serve where orderServeCode=#{orderServeCode} limit 1")
    public OrderServe getByOrderServeCode(@Param("orderServeCode") String orderServeCode);

    @Select("select * from order_serve where orderBusinessCode=#{orderBusinessCode}  limit 1")
    public OrderServe getByOrderBusinessCode(@Param("orderBusinessCode") String orderBusinessCode);

}
